<meta name="content-type" content="text/html; charset=UTF-8" />
<div class="panel-heading panel-result-title">
	<h3 class="panel-title">查询结果</h3>
	<div class="btn-group btn-group-sm btn-gp-default">
		<button id="btn_edit" type="button"
			onclick="window.location.href='yueyogaAdmin/toAddPlace.jhtml'"
			class="btn btn-default panel-radius-left">创建</button>
		<button id="btn_edit" type="button"
			class="btn btn-default panel-radius-none" onclick="updatePlace()">修改</button>
		<button id="btn_delete" type="button"
			class="btn btn-default panel-radius-right" onclick="deletePlace()">删除</button>
	</div>
</div>
<!--#if(totalspeakers== null || totalspeakers==0)-->
<div class="panel-body">
	<p>没有符合条件的数据</p>
</div>
<!--#else-->
<!--#var(Place place, PaginatedList<Place> placeList)-->

<table class="table table-bordered table-hover table-condensed">
		<tr class="tr-edit">
			<th style="text-align: center;" width="5%">
			<input type="checkbox" onclick="selectAll()" name="controlAll" style="" id="controlAll">
			</th>
			<th style="text-align: center;" width="25%">标题</th>
			<th style="text-align: center;" width="25%">类型</th>
			<th style="text-align: center;" width="25%">状态</th>
			<th style="text-align: center;" width="20%">添加时间</th>
		</tr>
		<!--#foreach(place in placeList)-->
		<tr>
			<!-- #if(place.status!=2) -->
			<td align="center"><input type="checkbox" name="selected" value="${place.id}"></td>
			<td align="center">${place.name}</td>
			<td align="center">
			<!-- #if(place.type==0) -->
			室内
			<!-- #else -->
			室外
			<!--#end-->
			</td>
			<td align="center">
			<!-- #if(place.status==1) -->
			使用中
			<!-- #else -->
			空闲中
			<!--#end-->
			</td>
			<td align="center">
			${place.createtime.format("yyyy-MM-dd")}
			</td>
		<tr>
		<!--#end-->
		<!--#end-->
	</tbody>
</table>
<!--
		#set(
		pager = placeList.pager,
		totalResults = pager.getCountOfTotalResults(),
		totalPages = pager.getCountOfTotalPages() * 1,
		pageSize = pager.pageSize,
		pageNo = pager.pageNo,
		prePageNo = pager.getPrevPageNo(),
		nextPageNo = pager.getNextPageNo()
		)
		-->
<div class="paging-page">$!{include("paging_page.html")}</div>
<!--#end-->
<script>
	function selectAll() {
		var checklist = document.getElementsByName("selected");
		if (document.getElementById("controlAll").checked) {
			for ( var i = 0; i < checklist.length; i++) {
				checklist[i].checked = 1;
			}
		} else {
			for ( var j = 0; j < checklist.length; j++) {
				checklist[j].checked = 0;
			}
		}
	}
	function deletePlace() {
		var checklist = document.getElementsByName("selected");
		var ids = "";
		for ( var i = 0; i < checklist.length; i++) {
			if (checklist[i].checked) {
				ids = ids + checklist[i].value + ",";
			}
		}
		if (ids == "") {
			alert("请选择要删除的行");
		} else {
			confirm("确定要删除吗", function() {
				this.close();
				ids = ids.substring(0, ids.length - 1);
				var d = wait("正在删除，请稍候...");
				var url = "yueyogaAdmin/deletePlace.jhtml?ids="+ ids;
				$.post(url, function(response) {
					if (response) {
						d.content("删除成功");
						setTimeout(function(){
							d.close().remove();
						}, 300);
						window.location.href = "yueyogaAdmin/findPlaceList.jhtml";
					} else {
						error("删除失败!");
					}
				}, "json");
			});
		}
	}
	function updatePlace() {
		var checklist = document.getElementsByName("selected");
		var id = "";
		var count = 0;
		for ( var i = 0; i < checklist.length; i++) {
			if (checklist[i].checked) {
				id = id + checklist[i].value;
				count++;
			}
		}
		if (count == 1) {
			window.location.href = "yueyogaAdmin/toEditPlace.jhtml?id=" + id;
		} else {
			alert("请选择一行进行编辑");
		}
	}
	function changePage(value) {
		value = value * 1;
		var totalPages = '${totalPages}';
		if (value > totalPages) {
			value = totalPages;
		} else if (value < 1) {
			value = 1;
		}
		$("#txtPageNumber").val(value);
		goToPage(value);
	}
	function goToPage(pageNo) {
		$("#hidPageNo").val(pageNo);
		document.taskForm.submit();
	}
</script>